﻿using System;

namespace ADEVSO.Xml
{
    public static class Xsl
    {
        /// <summary>
        /// Get XML Info based on XSL Structure
        /// </summary>
        /// <param name="strXMLFile"></param>
        /// <param name="strXSLFile"></param>
        /// <returns></returns>
        public static String Transform(String strXMLFile, String strXSLFile)
        {
            System.IO.StringWriter oSW = new System.IO.StringWriter();

            try
            {
                System.Xml.XmlTextReader oXR = new System.Xml.XmlTextReader(strXMLFile);
                //System.Xml.Xsl.XslCompiledTransform oXSLT2 = new System.Xml.Xsl.XslCompiledTransform();
                //oXSLT2.Load(strXSLFile);
                System.Xml.Xsl.XslCompiledTransform oXSLT = new System.Xml.Xsl.XslCompiledTransform();
                oXSLT.Load(strXSLFile);

                System.Xml.XPath.XPathDocument oXPath = new System.Xml.XPath.XPathDocument(oXR);
                //oXSLT2.Transform(oXPath, null, null, oSW);
                oXSLT.Transform(oXPath, null, oSW);
            }
            catch (System.Exception e)
            {
                String x = e.ToString();
            }

            return oSW.ToString();
        }
    }
}
